<?php
/*
*description:条形码生成
*author:李飞@天众科技
*time:2016/2/29
*/
namespace Admin\Controller;
use Think\Controller;
class BarcodeController extends CommonController {
	
    public function make_barcode(){
		$this->assign('warehouse_code',session('warehouse_code'));
		$area_code=C('base_config.area_code');
		if(empty($area_code)){
			echo ('请到“系统设置-基本配置”中配置变量名称为area_code,名称为区号的值');
			die;
		}
		$this->assign('area_code',$area_code);
		$this->assign('datetime',date('Ymd',time()));
        $this->display();
    }
	
	public function MakeBarcode(){
		$warehouse_code=session('warehouse_code');
		$area_code=C('base_config.area_code');
		$nums=I('nums');
		$m=M('Barcode',C('DB_PRS'),C('DB_DEPOT'));
		for($i=0;$i<$nums;$i++){
			$serialNumber=serialNumber('Barcode');
			$barcode=$warehouse_code.$area_code.date('Ymd',time()).$serialNumber;
			$arr[]=$barcode;
			$data['order_no']=$barcode;
			$data['add_time']=time();
			$m->add($data);
		}
		$this->ajaxReturn($arr);
    }

}